package com.qzsoft.zhjd.asphalt.modules.asphaltdatasieve.service.impl;

import java.util.List;
import java.util.Map;

import com.qzsoft.zhjd.asphalt.modules.asphaltdatasieve.dto.AsphaltDataSievingAvgDto;
import com.qzsoft.zhjd.asphalt.modules.asphaltdatasieve.dto.AsphaltDataSievingDto;
import com.qzsoft.zhjd.asphalt.modules.asphaltdatasieve.dto.ProduceSievePassRateDto;
import com.qzsoft.zhjd.asphalt.modules.asphaltdatasieve.entity.AsphaltDataSieveEntity;
import com.qzsoft.zhjd.asphalt.modules.asphaltdatasieve.mapper.AsphaltDataSieveMapper;
import com.qzsoft.zhjd.common.annotation.ZhjdDataFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qzsoft.zhjd.asphalt.modules.asphaltdatasieve.service.AsphaltDataSieveService;
import com.qzsoft.zhjd.common.components.BaseServiceComponent;

/**
 * @ClassName AsphaltDataSieveServiceImpl
 * @Description 筛孔业务接口实现
 * @author linhuawei
 * @since 2021-12-04
 */
@Service
public class AsphaltDataSieveServiceImpl extends ServiceImpl<AsphaltDataSieveMapper, AsphaltDataSieveEntity>
        implements AsphaltDataSieveService {

    @Autowired
    private BaseServiceComponent baseServiceComponent;

    @ZhjdDataFilter
    @Override
    public IPage<AsphaltDataSievingDto> pageDto(Map<String, Object> params) {
        IPage<AsphaltDataSievingDto> page = baseServiceComponent.getPage(params, AsphaltDataSievingDto.class);
        return baseMapper.queryDto(page, params);
    }

    @ZhjdDataFilter
    @Override
    public List<ProduceSievePassRateDto> produceSievePassRate(Map<String, Object> params) {
        // 判断筛孔数据是否为空
        String sieveSize = null == params.get("sieveSize") ? "0.075" : params.get("sieveSize").toString();
        if ("2.36".equals(sieveSize)) {
            sieveSize = "sieve2d36";
        } else if ("4.75".equals(sieveSize)) {
            sieveSize = "sieve4d75";
        } else {
            sieveSize = "sieve0d075";
        }
        params.put("sieveSize", sieveSize);

        // 返回查询结果
        return baseMapper.produceSievePassRate(params);
    }

    @Override
    public AsphaltDataSievingAvgDto getSievingAvg(Map<String, Object> params) {
        return baseMapper.sievingAvg(params);
    }

    @Override
    public List<AsphaltDataSieveEntity> listForDay(String stationCode, String matchCode, String day) {
        return baseMapper.listForDay(stationCode, matchCode, day);
    }

    @Override
    public AsphaltDataSievingAvgDto avgForDay(String stationCode, String matchCode, String day) {
        return baseMapper.avgForDay(stationCode, matchCode, day);
    }

}
